import wrapRequest from '../../../utils/request'
const shareUtils = require('../../../utils/share')
const swiperList = [{
		value: "//gw.alicdn.com/i2/2884643658/O1CN01B2PjAQ1ctPiTtTu5f_!!0-item_pic.jpg_Q75.jpg",
		ariaLabel: "挥春1",
	},
	{
		value: `//gw.alicdn.com/i3/322784306/O1CN01kwhhZF1hgCJvGdFig_!!322784306.jpg_Q75.jpg`,
		ariaLabel: '挥春2',
	},
	{
		value: `//gw.alicdn.com/i1/2206438638725/O1CN010ZJaB02EK6aSNf9Za_!!0-item_pic.jpg_Q75.jpg`,
		ariaLabel: '挥春3',
	},
	{
		value: `//gw.alicdn.com/i4/2211491645863/O1CN01mOX4aq1tBJ2BADHbN_!!0-item_pic.jpg_Q75.jpg`,
		ariaLabel: '挥春4',
	},
	{
		value: `//gw.alicdn.com/i4/2212490562654/O1CN012EaVAj1VTa4t1WICS_!!0-item_pic.jpg_Q75.jpg`,
		ariaLabel: '挥春5',
	},
];
const tagList = [{
		"desc": "假一赔十"
	},
	{
		"desc": "7天无理由退货"
	},
	{
		"desc": "破损包退"
	},
	{
		"desc": "极速退款"
	},
	{
		"desc": "店铺发货&售后"
	},
	{
		"desc": "可配送港澳台"
	},
]
const descList = [{
		"text": "内容巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴巴拉巴拉巴拉巴巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉...",
		"image": "//gw.alicdn.com/i3/2204161786790/O1CN01bbQTNP201sBkrWRMl_!!0-item_pic.jpg_Q75.jpg",
	},
	{
		"text": "内容巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴巴拉巴拉巴拉巴巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉...",
		"image": "//gw.alicdn.com/i3/2679099669/O1CN01wrvsGz2LISSCLYLOe_!!2679099669.jpg_Q75.jpg",
	},
	{
		"text": "内容巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴巴拉巴拉巴拉巴巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉...",
		"image": "//gw.alicdn.com/i3/2211497900219/O1CN01K2Rtwb1DULe9hIOnd_!!0-item_pic.jpg_Q75.jpg",
	},
]
Page({
	data: {
		swiperList,
		tagList,
		descList,
		fabButton: {
			icon: 'share',
			openType: 'share',
		},
		id: 0,
		product: {}
	},
	onLoad(options) {
		console.log("options:", options)
		this.setData({
			id: options.id
		})
		this.getMarketDetail(options.id)
	},
	handleClick(e) {
		console.log(e);
	},
	getMarketDetail(id) {
		let that = this
		wrapRequest('/v1.0/huichun/market/detail/' + id, 'GET', {
			success: function (res) {
				that.setData({
					product: res.data.data,
					swiperList: [res.data.data.pic, ...swiperList]
				})
			}
		})
	},
	onCollect(e) {
		var that = this
		const collect = e.currentTarget.dataset.collect
		var product = this.data.product
		wrapRequest('/v1.0/huichun/mine/collect', 'POST', {
			data: {
				product_id: product.id,
				collect: collect,
			},
			success: function (res) {
				product.is_collect = collect
				that.setData({
					product: product,
				})
			}
		})
	},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {
		return shareUtils.getShareConfig();
	},
	onShareTimeline() {
		return shareUtils.getShareConfig();
	}
})